cmake_minimum_required(VERSION 3.14)

project(ZTestLib LANGUAGES CXX)

# Qt 自动生成的依赖项
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

# 使用C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Qt 自动生成的依赖项
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

# 搜索当前目录下的此类型后缀文件
file(GLOB SourceFiles "*.h" "*.cpp")
# SHARED表示编译动态库,STATIC是静态库
add_library(${PROJECT_NAME} SHARED
        # 项目集成搜索到的文件
        ${SourceFiles}
        )

# 项目链接库
target_link_libraries(${PROJECT_NAME} PRIVATE
        Qt${QT_VERSION_MAJOR}::Widgets
        )

# 用于ZTestLib_global.h文件中
target_compile_definitions(${PROJECT_NAME} PRIVATE ZTESTLIB_LIBRARY)

# 指定.h所在目录,暴露给其他程序
target_include_directories(${PROJECT_NAME} PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
        $<INSTALL_INTERFACE:include>  # <prefix>/include
        )
